﻿function InitGrid() {
    var mainTable = $("#DialogGrid_DXMainTable").css('table-layout', 'auto');
    mainTable.find("[id*='DialogGrid_DXDataRow'] td").css("border-width", "1px").children("div").remove();
    $("#DialogGrid_DXMainTable").find("#DialogGrid_DXHeadersRow td").width("auto");
    $("#DialogGrid_DXMainTable colgroup").remove();
}
InitGrid();

function ResizeGrid() {
    var dialogSelIndex = parent.parent.$("#hiddenDialogSelIndex");
    var dialogIndex = parseInt(dialogSelIndex.val()) - 1;

    var contentHeight = parent.parent.$("#dialogSel" + dialogIndex + "_CIFD-1").height() - parent.$("#panelButtons").height() - parent.$("#panelStdQueryParam").height();
    //alert("contentHeight:"+contentHeight);
    var stdQueryGrid = $("#DialogGrid > tbody > tr > td");

    var heightSum = 0;
    //alert("tabHeight:" + heightSum);
    var tableHeater = $("#DialogGrid_DXHeaderTable").parent();
    if (tableHeater.length == 1) {
        //alert("tableHeater:" + tableHeater.height());
        heightSum += tableHeater.height() + 1;
    }
    var sumFooter = $("#DialogGrid_DXFooterTable");
    if (sumFooter.length == 1) {
        //alert("sumFooter:" + sumFooter.height());
        heightSum += sumFooter.height() + 1;
    }

    var paperFooter = $("#DialogGrid_DXPagerBottom").parent();
    if (paperFooter.length == 1) {
        //alert("paperFooter:" + paperFooter.height());
        heightSum += paperFooter.height() + 1;
    } else {
        heightSum += 6;
    }

    var groupPanel = stdQueryGrid.children("[class*='dxgvGroupPanel']");
    if (groupPanel.length == 1) {
        //alert("groupPanel:" + groupPanel.height());
        heightSum += groupPanel.height() + 1;

    }

    var emptyRow = stdQueryGrid.children("[class*='dxgvEmptyDataRow']");
    if (emptyRow.length == 1) {
        //emptyRow.height(contentHeight - heightSum - 10);
    }
    else {
        var themeHeight = 0;
        switch ($("#hfThemeName").val()) {
            case "Default": themeHeight = 0;
                break;
            case "Aqua":
            case "Office2003Olive":
            case "Office2003Blue":
            case "Office2003Silver": themeHeight = 0; break;
            case "PlasticBlue": themeHeight = -2;break;
        }
        var height = contentHeight - heightSum - themeHeight - 20;
        $("#DialogGrid_DXMainTable").parent().height(height);
    }
}
ResizeGrid();


